package pub.gll.onepeas.libbase.taskchain

import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AlertDialog

class TaskJobTwo : SingleJob {
    var flag = SingleJob.JOB_NOT_AVAILABLE
    var data: Bundle? = null
    override fun handle(): Boolean {
        println("start handle job one")
        return  flag != SingleJob.JOB_CANCELED
    }
    override fun launch(context: Context, callback: () -> Unit) {
        println("start launch job one")
        val type = data?.getString("dialog_type")
        AlertDialog.Builder(context).setMessage(if(type != null)"这是第一个${type}弹框" else "这是第一个弹框")
            .setPositiveButton("ok") {x,y->
                callback()
            }.show()
    }
    override fun setStatus(level: Int) {
        if(flag != SingleJob.JOB_COMBINED_BY_NOTHING)
            this.flag = level
    }
    override fun status(): Int = flag

    override fun setBundle(bundle: Bundle) {
        this.data = bundle
    }
}